<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>p14v-if和v-show</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.10/vue.js"></script>
</head>
<body>
    <div id="app">
        <input type="button" @click="toggle" value="toggle">
        <!-- v-if的特点：每次都会重新删除或创建元素 -->
        <!-- 有较高的切换性能消耗 -->
        <h3 v-if="flag">这是v-if控制的值</h3>
        <!-- v-show的特点:每次不会重新进行dom的删除和创建操作，只是切换了元素的display：none属性 -->
        <!-- 有较高的初始化渲染消耗 -->
        <h3 v-show="flag">这是v-show控制的值</h3>
    </div>
    <script>
        var vm=new Vue({
            el:"#app",
            data:{
                flag:true
            },
            methods:{
                toggle(){
                    this.flag=!this.flag
                }
            }
        })
    </script>
</body>
</html>